# -*-  coding:utf-8 -*- 
# Author : lihongliang
"""   
info_dict = {
    "stu001":"tang",
    "stu002":"aliang",
    "stu003":"alex",
}

print(info_dict)
info_dict["bbb"]="bbb"
info_dict["ccc"]="ccc"
info_dict["aaa"]="aaa"
print(info_dict)
info_dict["stu001"]="wutenglan"
print(info_dict)


info_dict.popitem()
print(info_dict)

# info_dict.pop("stu001")
# print(info_dict)
#
# del info_dict["stu002"]
# print(info_dict)


print("stu001" in  info_dict)
print(info_dict.get("123"))


print(info_dict.values())
print(info_dict.keys())

print(info_dict.setdefault("stu010","010test"))
print(info_dict)
print(info_dict.setdefault("aaa","abcdefsfa"))
print(info_dict)
a={"a":"a","b":"b", "c":"c"}
info_dict.update(a)
print(info_dict)

print("分割线".center(50,"*"))
for key in info_dict:
    print(key,info_dict[key])
"""



menu ={
    "广东省":{
        "珠海市":{
            "香洲区":["香洲一区","香洲五区","香洲十区"],
            "斗门区":["斗门一区","斗门五区","斗门十区"],
            "金湾区":["金湾一区","金湾五区","金湾十区"]
        },
        "广州市":{
            "天河区":["天河一区","天河五区","天河十区"],
            "番禺区":["香洲一区","香洲五区","香洲十区"],
            "花都区":["香洲一区","香洲五区","香洲十区"]
        },
        "深圳市":{
            "罗湖区":["罗湖一区","罗湖五区","罗湖十区"],
            "福田区":["福田一区","福田五区","福田十区"],
            "南山区":["南山一区","南山五区","南山十区"]
        }
    },
    "陕西省":{
        "西安市":{
            "新城区",
            "未央区",
            "雁塔区"
        },
        "咸阳市":{
            "秦都区",
            "杨陵区",
            "渭城区"
        },
        "宝鸡市":{
            "渭滨区",
            "金台区",
            "陈仓区"
        }
    },
    "四川省":{
        "成都市":{
            "锦江区",
            "青羊区",
            "金牛区"
        },
        "自贡市":{
            "自流井区",
            "贡井区",
            "大安区"
        },
        "德阳市":{
            "中江县",
            "罗江县",
            "广汉市"
        }
    }
}

"""  
print("＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝多级菜单＝＝＝＝＝＝＝＝＝＝＝＝＝")
q_flag = True
current_layer = menu
last_layer = [menu]

while q_flag:
    print("显示当前信息".center(50,"*"))
    for i  in current_layer:
        print(i)
    choice = input("请输入要进入的菜单：")
    if  choice  in  current_layer:
        if current_layer[choice]:
            last_layer.append(current_layer)
            current_layer = current_layer[choice]
        else:
            print("当前是最后一页")
    elif choice == "q":
        q_flag = False
    elif choice == "b":
        if current_layer :
            current_layer = last_layer[-1]
            last_layer.pop()
    else:
        print("输入有误，请重新输入！")

"""

exit_flag = False
while  not exit_flag:
    for i in menu:
        print(i)
    choice = input("选择进入1：")
    if choice in menu:
        while not exit_flag:
            for i2 in menu[choice]:
                print("\t",i2)
            choice2 = input("请选择输入2：")
            if choice2 in menu[choice]:
                while  not  exit_flag:
                    for i3 in menu[choice][choice2]:
                        print("\t",i3)
                    choice3 = input("请选择输入3：")
                    if choice3  in menu[choice][choice2]:
                        for i4 in menu[choice][choice2][choice3]:
                            print("\t\t", i4)
                        choice4 = input("最后一层，按b返回")
                        if choice4 == "b":
                            pass
                        elif choice4 == "q":
                            exit_flag = True
                    elif choice3 == "b":
                        break
                    elif choice3 == "q":
                        exit_flag =True
                    else:
                        print("3输入错误")
            elif choice2 == "b":
                break
            elif choice2 == "q":
                exit_flag = True
            else:
                print("2输入错误！")
    elif choice == "q":
        exit_flag = True
    else:
        print("1输入错误！")















